package com.example.baselibrary.utlis

import android.os.SystemClock

/**
 * 全局点击控制器，共享点击状态
 * 适用于多个相关联按钮需要共享点击状态的情况
 */
class GlobalClickController(private val interval: Long = 500) {
    private var lastClickTime: Long = 0

    fun onClick(action: () -> Unit) {
        val currentTime = SystemClock.elapsedRealtime()
        if (currentTime - lastClickTime >= interval) {
            lastClickTime = currentTime
            action()
        }
    }
}